<template>
	<view class="main">
		<tou_hand1 handtitle='订单详情'></tou_hand1>
		<view class="show">
			
			<view class="one">
				<view class="oneleft">
					<image src="https://qiniu.jxyutuo.com/yanqin/tabBarimg//cdxselect.png"></image>
					<input placeholder='设备号搜索' v-model="name" />
				</view>
				<view class="oneright" @click="selbtn">搜索</view>
			</view>
			<van-pull-refresh v-model="refreshing" @refresh="onRefresh">
			<van-list v-model="loading" :offset="300" :finished="finished" finished-text="没有更多了" @load="loadMore">
			<van-cell v-for="(item, index) in blist" :key="index" >
					<view class="two">
						<view class="twofirst">
							<view class="twofirstleft">
								设备编号：{{item.code}}
							</view>
						</view>
						<view class="twosecond">
							<view class="twosecondleft">
								端口数量：<span>{{item.portsNum}}</span>
							</view>
						</view>
						<view class="twosecond">
							<view class="twosecondleft">
								保单号：
								<span v-if="item.insureOrder">{{item.insureOrder}}</span>
								<span v-else style="color: #4B98ED;">生成中</span>
							</view>
						</view>
						<view class="twosecond">
							<view class="twosecondleft">
								保单开始时间：
								<span v-if="item.insureStartTime">{{item.insureStartTime}}</span>
								<span v-else>-</span>
							</view>
						</view>
						<view class="twosecond">
							<view class="twosecondleft">
								保单开始时间：
								<span v-if="item.insureEndTime">{{item.insureEndTime}}</span>
								<span v-else>-</span>
							</view>
						</view>
						<view class="twosecond">
							<view class="twosecondleft">
								设备位置：<span>{{item.projectName}}-{{item.areaName}}</span>
							</view>
							<view class="twosecondright" @click="pzbtn(index)" v-show="item.insureOrder">
								场地险凭证
							</view>
						</view>
					</view>
			</van-cell>
			</van-list>
			</van-pull-refresh>	
		</view>
		
	</view>
</template>

<script>
	import tou_hand1 from '../../components/tou_hand1/tou_hand1.vue'
	
	export default {
		components: {tou_hand1},
		mounted() {
			
		},

		data() {
			return {
				name:'',
				orderNo:'',
				blist:[],//本区消费数据
				loading: false,
				finished: false,
				refreshing: false,
				pageNum: 1, //页码
				pageSize: 10, //每页显示的条数
			}
		},
		onLoad(option) {
			this.orderNo=option.orderNo
			this.loadMore();
		},
		methods: {
			// 用户统计详情分页
			loadMore() {
				if (this.refreshing) {
				  this.blist = [];
				  this.refreshing = false;
				}
				const that = this;
				let data = {
					pageNum:that.pageNum,
					pageSize:that.pageSize,
					insureOrder:this.orderNo,
					deviceId:this.name
				}
				that.loading = true;
				that.$base.request1('manager/insure/list', 'POST', data)
					.then(res => {
						that.loading = false;
						if(res.data.code==0){
							that.money=res.data.msg
							if(res.data.rows&&res.data.rows.length>0){
								that.blist = that.blist.concat(res.data.rows);
								that.pageNum += 1;
							}else{
								that.finished = true;
							}
						}else{
							that.finished = true;
						}
						
					})
					.catch(err => {
				
					})
			},
			 onRefresh() {
			      // 清空列表数据
			      this.finished = false;
				  this.pageNum=1
			      // 重新加载数据
			      // 将 loading 设置为 true，表示处于加载状态
			      this.loading = true;
			      this.loadMore();
			    },
			pzbtn(index){
				var item=this.blist[index]
				uni.navigateTo({
					url:'/pages/site_insurance_certificate/site_insurance_certificate?insureOrder='
					+item.insureOrder+'&insureStartTime='+item.insureStartTime+'&insureEndTime='+item.insureEndTime
					+'&projectName='+item.projectName+'&areaName='+item.areaName+'&userId='+uni.getStorageSync('userId')
					+'&code='+item.code
				})
			},
			selbtn(){
				this.blist=[]
				this.onRefresh()
			}
			
		}
	}
</script>

<style lang="scss" scoped>
	.main {
		width: 100%;
		/deep/.van-list__finished-text{
			margin-top: 100upx;
			padding-bottom: 200upx;
		}
		/deep/.van-hairline--top-bottom::after{
			border-width: 0;
		}
		
		.show{
			width: 100%;
			padding: 0 26upx;
			box-sizing: border-box;
			/deep/.van-cell{
				box-shadow: 0px 14upx 16upx 1upx rgba(22,86,176,0.2);
				border-radius: 10upx;
				padding: 36upx 20upx;
				width: 99%;
				margin: 0 auto;
				margin-top: 28upx;
			}
			.one{
				width: 100%;
				box-sizing: border-box;
				display: flex;
				align-items: center;
				justify-content: center;
				margin-top: 20upx;
				.oneleft{
					width: 85%;
					box-sizing: border-box;
					text-align: center;
					display: flex;
					border-radius: 44upx;
					padding: 15upx 20upx;
					background-color:#F5F5F5;
					align-items: center;
					margin-right: 26upx;
					image {
						width: 34upx;
						height: 34upx;
					}
					
					input {
						width: 100%;
					}
					
					/deep/.uni-input-placeholder {
						font-size: 30upx;
						font-family: PingFang-SC-Regular-, PingFang-SC-Regular;
						font-weight: normal;
						color: #CECECE;
						line-height: 36upx;
					}
				}
				.oneright{
					font-size: 32upx;
					font-family: PingFang SC-Bold, PingFang SC;
					font-weight: bold;
					color: #4B98ED;
					line-height: 38upx;
				}
			}
			.two{
				width: 100%;
				box-sizing: border-box;
				
				.twofirst{
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-bottom: 15upx;
					.twofirstleft{
						font-size: 32upx;
						font-family: PingFang SC-Heavy, PingFang SC;
						font-weight: 800;
						color: #666666;
						line-height: 38upx;
						span{
							color: #4B98ED;
						}
					}
					.twofirstright{
						font-size: 24upx;
						font-family: PingFang-SC-Regular-, PingFang-SC-Regular;
						font-weight: normal;
						color: #999999;
						line-height: 29upx;
					}
				}
				.twosecond{
					width: 100%;
					display: flex;
					align-items: center;
					justify-content: space-between;
					margin-bottom: 15upx;
					.twosecondleft{
						width: 68%;
						overflow: hidden; //超出的文本隐藏
						text-overflow: ellipsis; //溢出用省略号显示
						white-space: nowrap;  // 默认不换行；
						font-size: 26upx;
						font-family: PingFang-SC-Regular-, PingFang-SC-Regular;
						font-weight: normal;
						color: #999999;
						line-height: 31upx;
						span{
							color: #666666;
						}
					}
					.twosecondright{
						text-align: center;
						font-size: 17upx;
						font-family: Yu Gothic UI-Regular, Yu Gothic UI;
						font-weight: 400;
						color: #0083FF;
						line-height: 22upx;
						padding: 12upx 36upx;
						border: 2upx solid #0083FF;
						border-radius: 10upx;
					}
				}
			}
		}
	}
</style>
